<template>
  <h1>菜单组件</h1>
  <el-menu mode="horizontal" active-text-color="#ff0"
           background-color="#4F8DFE" text-color="#fff"
           @select="handleSelect">
    <el-menu-item index="1">首页</el-menu-item>
    <el-menu-item index="2">免费课</el-menu-item>
    <el-menu-item index="3">直播课</el-menu-item>
    <el-menu-item index="4">精品课</el-menu-item>
    <el-menu-item index="5">线上班</el-menu-item>
    <el-sub-menu index="6">
      <template #title>线下班</template>
      <el-menu-item index="6-1">JSDTN2406</el-menu-item>
      <el-menu-item index="6-2">JSDTN2407</el-menu-item>
      <el-menu-item index="6-3">JSDTN2408</el-menu-item>
    </el-sub-menu>
  </el-menu>
</template>

<script setup>
/*index 指的是选择了哪个菜单项，对应每个菜单项的index值，比如5对应的是选择了“线上班”
* indexPath 表示选中当前菜单项走过的路径，比如[6,6-2]选中线下班下的JSDTN2407*/
const handleSelect = (index, indexPath) => {
  console.log(index, indexPath);
}
</script>

<style scoped>

</style>



















